package cn.baizhi.controller;


import cn.baizhi.service.AdminService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LZM
 * @since 2021-11-24
 */
@Controller
@RequestMapping("/admins")
@CrossOrigin
public class AdminController {

    private static final Logger log = LoggerFactory.getLogger(AdminController.class);
    @Autowired
    private AdminService as;

    @GetMapping("/{username}/{password}")
    public ResponseEntity<Map<String,Object>> login(@PathVariable String username,@PathVariable String password){
        log.debug("用户名: {}, 密码: {}",username,password);
        Map<String, Object> map = as.login(username, password);

        return new ResponseEntity<>(map, HttpStatus.OK);

    }


}

